var echarts = require("echarts");
/* let charthead2 = {
  tooltip: {
    trigger: 'item'
  },
  legend: {
    itemGap: 15,
    itemWidth: 30,
    itemHeight: 20,
    orient: 'vertical',
    right: 10,
    top: 20,
    textStyle: {
      color: '#ffffff',
      fontSize: 16,
    },
    formatter:function(name){
      let data  = this.chartHeadArry ;
      let total = 0 ;
      let tarValue = 0;
      for(let i =0 ;i<data.length;i++){
        total += parseInt(data[i].value);
        if(data[i].name == name){
          tarValue = data[i].value;
        }
      }
      let arr = ['{a|'+name+'}','{b|'+((tarValue/total)*100).toFixed(2)+'%}']
      return arr.join('')
    }
  },
  toolbox: {
    show: false,
    feature: {
      mark: {
        show: true
      },
      dataView: {
        show: true,
        readOnly: false
      },
      restore: {
        show: true
      },
      saveAsImage: {
        show: true
      }
    }
  },
  series: [{
    name: '评价',
    type: 'pie',
    radius: ['35%', '90%'],
    center: ['40%', '50%'],
    //roseType: 'area',
    data: [
      //{ value: 38, name: '5 星' },
      // { value: 26, name: '1 星' } 
    ],
    label: {
      show: false,
    },
    labelLine: {
      show: false
    },
    emphasis: {
      label: {
        show: false,
        fontSize: 40,
        fontWeight: 'bold'
      }
    },
  },
  //内圈百分比
  {
    type: "pie",
    center: ["40%", "50%"],
    radius: ["00%", "50%"], //内圆的半径，第一个为内半径，第二个为外半径
    avoidLabelOverlap: false,
    color: ["#000042"],
    data: [{
      hoverOffset: 1,
      value: "0",
      position: "center",
      name: "",
      itemStyle: {
        color: "#000042",
      },
      label: {
        normal: {
          formatter: "评价总数\n\n{c}",
          textStyle: {
            fontWeight: "normal",
            fontSize: 28,
          },
          show: true,
          position: "center",
          color: "#fff",
        },
      },
      labelLine: {
        normal: {
          smooth: true,
          lineStyle: {
            width: 0,
          },
        },
      },
      hoverAnimation: false,
    }, ],
  },
  ]
}; */
let charthead1a = {
  tooltip: {
    trigger: 'item'
  },
  color: ['#f55301', '#0f157c'], //#5fb878
  series: [{
    name: '工单追踪',
    type: 'pie',
    radius: ['60%', '80%'],
    /* center: ['50%', '30%'], */
    avoidLableOverlap: false,
    hoverAnimation: false,
    selectedOffset: 0,
    label: {
      show: false,
      position: 'center',
      formatter: '{d}%',
      textStyle: {
        fontSize: 22,
        color: '#fff',
        fontWeight: 400,
        font: '22px 微软雅黑'
      },
    },
    emphasis: {
      label: {
        show: true,
        fontSize: '28',
        fontWeight: 'bold'
      }
    },
    labelLine: {
      show: false
    },
    itemStyle: {
      borderWidth: 1,
      borderColor: '#0f157c',
    },
    data: [{
      value: [],
      name: '',
      selected: true,
      label: {
        show: true,
        fontsize: '20',
        fontWeight: 'bold'
      }
    },
    {
      value: [],
      name: ''
    },
    ]

  },
  //内圈百分比
  {
    type: "pie",
    center: ["50%", "50%"],
    radius: ["00%", "50%"], //内圆的半径，第一个为内半径，第二个为外半径
    avoidLabelOverlap: false,
    color: ["#699560"],
    data: [{
      hoverOffset: 1,
      value: "0",
      position: "center",
      name: "",
      itemStyle: {
        color: "#699560",
      },
      label: {
        normal: {
          formatter: "进行中\n{c}%",
          textStyle: {
            fontWeight: "normal",
            fontSize: 18,
          },
          show: true,
          position: "center",
          color: "#fff",
        },
      },
      labelLine: {
        normal: {
          smooth: true,
          lineStyle: {
            width: 0,
          },
        },
      },
      hoverAnimation: false,
    },],
  },
  ]
};
let charthead1b = {
  tooltip: {
    trigger: 'item'
  },
  color: ['#5263ff', '#0f157c'], //#5fb878
  title: {
    //text: '工单追踪'
  },
  series: [{
    name: '工单追踪',
    type: 'pie',
    radius: ['60%', '80%'],
    /* center: ['50%', '30%'], */
    avoidLableOverlap: false,
    hoverAnimation: false,
    selectedOffset: 0,
    label: {
      show: false,
      position: 'center',
      formatter: '{d}%',
      textStyle: {
        fontSize: 22,
        color: '#fff',
        fontWeight: 400,
        font: '22px 微软雅黑'
      },
    },
    emphasis: {
      label: {
        show: true,
        fontSize: '28',
        fontWeight: 'bold'
      }
    },
    labelLine: {
      show: false
    },
    itemStyle: {
      borderWidth: 1,
      borderColor: '#0f157c',
    },
    data: [{
      value: [],
      name: '',
      selected: true,
      label: {
        show: true,
        fontsize: '20',
        fontWeight: 'bold'
      }
    },
    {
      value: [],
      name: ''
    },
    ]

  },
  //内圈百分比
  {
    type: "pie",
    center: ["50%", "50%"],
    radius: ["00%", "50%"], //内圆的半径，第一个为内半径，第二个为外半径
    avoidLabelOverlap: false,
    color: ["#699560"],
    data: [{
      hoverOffset: 1,
      value: "0",
      position: "center",
      name: "",
      itemStyle: {
        color: "#699560",
      },
      label: {
        normal: {
          formatter: "已完成\n{c}%",
          textStyle: {
            fontWeight: "normal",
            fontSize: 18,
          },
          show: true,
          position: "center",
          color: "#fff",
        },
      },
      labelLine: {
        normal: {
          smooth: true,
          lineStyle: {
            width: 0,
          },
        },
      },
      hoverAnimation: false,
    },],
  },
  ]
};
let charthead1c = {
  tooltip: {
    trigger: 'item'
  },
  color: ['#5fb878', '#0f157c'], //#5fb878
  title: {
    //text: '工单追踪'
  },
  series: [{
    name: '工单追踪',
    type: 'pie',
    radius: ['60%', '80%'],
    /* center: ['50%', '30%'], */
    avoidLableOverlap: false,
    hoverAnimation: false,
    selectedOffset: 0,
    label: {
      show: false,
      position: 'center',
      formatter: '{d}%',
      textStyle: {
        fontSize: 22,
        color: '#fff',
        fontWeight: 400,
        font: '22px 微软雅黑'
      },
    },
    emphasis: {
      label: {
        show: true,
        fontSize: '28',
        fontWeight: 'bold'
      }
    },
    labelLine: {
      show: false
    },
    itemStyle: {
      borderWidth: 1,
      borderColor: '#0f157c',
    },
    data: [{
      value: [],
      name: '',
      selected: true,
      label: {
        show: true,
        fontsize: '20',
        fontWeight: 'bold'
      }
    },
    {
      value: [],
      name: ''
    },
    ]

  },
  //内圈百分比
  {
    type: "pie",
    center: ["50%", "50%"],
    radius: ["00%", "50%"], //内圆的半径，第一个为内半径，第二个为外半径
    avoidLabelOverlap: false,
    color: ["#699560"],
    data: [{
      hoverOffset: 1,
      value: "0",
      position: "center",
      name: "",
      itemStyle: {
        color: "#699560",
      },
      label: {
        normal: {
          formatter: "未开始\n{c}%",
          textStyle: {
            fontWeight: "normal",
            fontSize: 18,
          },
          show: true,
          position: "center",
          color: "#fff",
        },
      },
      labelLine: {
        normal: {
          smooth: true,
          lineStyle: {
            width: 0,
          },
        },
      },
      hoverAnimation: false,
    },],
  },
  ]
};
let chartcenter = {
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'cross',
      crossStyle: {
        color: '#999'
      }
    }
  },
  toolbox: {
    feature: {
      // dataView: { show: true, readOnly: false },
      // magicType: { show: true, type: ['line', 'bar'] },
      // restore: { show: true },
      // saveAsImage: { show: true }
    }
  },
  legend: {
    data: ['任务量', '完成率'],
    textStyle: {
      color: "#fff",
      fontSize: "12"
    }
  },
  xAxis: [
    {
      type: 'category',
      data: [],
      axisPointer: {
        type: 'shadow'
      },
      axisLabel:{
        color:'#fff',
        rotate:45,
      }
    }
  ],
  yAxis: [
    {
      type: 'value',
      name: '任务量',
      nameTextStyle: {
        color: '#fff',
      },
      axisLabel: {
        textStyle: {
          color: '#fff ',
          margin:15,
        }
      },
      min: 0,
      splitNumber: 5,
      axisLabel: {
        formatter: '{value} '
      },
      axisLabel:{
        color:'#fff',
      }
    },
    {
      type: 'value',
      name: '完成率',
      nameTextStyle: {
        color: '#fff',
      },
      min: 0,
      max: 100,
      splitNumber: 5,
      axisLabel: {
        formatter: '{value} %',
        color:'#fff',
      },
    },
    
  ],
  series: [
    {
      name: '任务量',
      type: 'bar',
      tooltip: {
        valueFormatter: function (value) {
          return value;
        }
      },
      data: [],
      itemStyle:{
        color:'#6f7ad3',
      },
      label: {
        show: 'true',
        color: '#fff',
        fontWeight: 'bold',
        fontSize: 12,
        verticalAlign: 'top',
        position: 'top',
      }
    },
    {
      name: '完成率',
      type: 'line',
      yAxisIndex: 1,
      tooltip: {
        valueFormatter: function (value) {
          return value + ' %';
        }
      },
      data: [],
      itemStyle:{
        color:'#6aa',
      },
    }
  ],
};
export {
  //charthead2,
  charthead1a,
  charthead1b,
  charthead1c,
  chartcenter
}